/*--------James Fosco Variables--------*/
var markersArray = [];
var locArray = [];
var map;
var stanford = new google.maps.LatLng(37.428899,-122.169857);
var browserSupportFlag =  new Boolean();
var geoloc = null;
var usrname = "-1";

var memberInfo = function(id, name, marker) {
		this.id = id;
		this.name = name;
		this.marker = marker;
	}
/*--------End James Fosco Variables--------*/

function initialize() {
  /*--------James Fosco--------*/
  var mapOptions = {
    zoom: 12,//need to find correct value
    center: stanford,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    
  map =  new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
  
  if(navigator.geolocation) {
	    browserSupportFlag = true;
	    navigator.geolocation.getCurrentPosition(function(position) {
			var lat = position.coords.latitude;
			var lng = position.coords.longitude;
			console.log("lat: " + lat + ", lng: " + lng);
			geoloc = new google.maps.LatLng(lat, lng);
			map.setCenter(geoloc);
			//Remove once Brett GTG
			//addLocMarker("1", "James", geoloc.lat(), geoloc.lng());
		}, function() {
		    handleNoGeolocation(browserSupportFlag);
		});
  } else {
  	browserSupportFlag = false;
 	handleNoGeolocation(browserSupportFlag);
  }
  /*--------End James Fosco--------*/
}

function handleNoGeolocation(errorFlag) {
    if (errorFlag == true) {
	alert("Geolocation service failed.");
	geoloc = stanford;
    } else {
	alert("Your browser doesn't support geolocation. We've placed you in Siberia.");
	geoloc = stanford;
    }
    map.setCenter(location);
}